package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.bean.Power;

import java.util.List;

/**
 * @Auther:Liu
 * @Testname:PowerMapper
 * @Date:2025/8/8 10:10
 */
@Mapper
public interface PowerMapper extends BaseMapper<Power> {

    @Select("select * from power where id in(select power_id from user_power where user_id=#{userId})")
    List<Power> FindPowersToUser(String userId);

    @Select("select name from power where id in(select power_id from user_power where user_id=#{userId})")
    List<String> FindPowersToUser2(String userId);

    //删除用户权限
    @Delete("delete from user_power where user_id=#{userId}")
    int removeByUserIds(String userId);

    //添加用户权限
    @Insert("insert into user_power values(null,#{userId},#{powerId},now())")
    int insertPowerByUserId(@Param("userId") String userId, @Param("powerId") String powerId);

}
